package com.www.applyword.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.www.applyword.R;
import com.www.applyword.ui.home.HomeSignInActivity;

import java.util.List;

public class GirdDropDownAdpter3 extends BaseAdapter {
    private HomeSignInActivity context;
    private List<String> beanList;
    private LayoutInflater inflater;



    public GirdDropDownAdpter3(Context context, List<String> beanList) {
        this.context = (HomeSignInActivity) context;
        this.beanList = beanList;
        inflater = LayoutInflater.from(context);
    }

    @Override
    public int getCount() {
        return beanList.size();
    }

    @Override
    public Object getItem(int position) {
        return beanList.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder holder;
        if(convertView == null){
            holder = new ViewHolder();
            convertView = inflater.inflate(R.layout.item_job_work2,null);
            holder.item_city_name_tv = convertView.findViewById(R.id.tv);
            holder.tv_fen = convertView.findViewById(R.id.tv_fen);
            holder.rl = convertView.findViewById(R.id.rl);
            convertView.setTag(holder);
        }else {
            holder = (ViewHolder) convertView.getTag();
        }
        holder.item_city_name_tv.setText(beanList.get(position));
        if (position == 6){
            holder.tv_fen.setText("+10");
        }

        if (context.flag){
            if(position == 0){
                holder.tv_fen.setText("✔");
                holder.rl.setBackgroundResource(R.drawable.shape_cl3);
            }
        }
        return convertView;
    }

    class ViewHolder {
        private TextView item_city_name_tv,tv_fen;
        private RelativeLayout rl;
    }
}
